# 定义 发短信的任务
import random

# from app.select import app
from celery_tasks.main import celery_app
from ronglian_sms_sdk import SmsSDK


@celery_app.task()
def ccp_send_sms_code():
    #             'account_id'                      'token'          'appid'
    sms_code = '%04d' % random.randint(0, 9999)
    mobile = '19836061087'
    sdk = SmsSDK('2c94811c8cd4da0a018fcea058db2e0d',
                 '6b5c9b29394d4944b1550251493cdf95',
                 '2c94811c8cd4da0a018fcea05a762e14')
    # 短信模板,手机号,  ('短信内容'),
    result = sdk.sendMessage('1', mobile, (sms_code, 3))
    print('短信验证码',sms_code)
    return result
